package com.blogspot.mikelaud.cbs;

//import org.apache.maven.execution.MavenSession;
//import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;

import java.io.File;

/**
 * Goal which create a Makefile.
 */
@Mojo
(	name = "makefile"
,	defaultPhase = LifecyclePhase.PROCESS_SOURCES		
)
@Execute
public class CbsMojo extends AbstractMojo {
    
	//========================================================================
	/*
    @Component
    private MavenSession mSession;

    @Component
    private MojoExecution mMojo;
    
    @Component(role = Makefile.class)
    private Makefile mMakefile;
	 */

    @Component
    private MavenProject mProject;
    
    @Component
    private PluginDescriptor mPlugin;

    @Component
    private Settings mSettings;

	//------------------------------------------------------------------------
    
	@Parameter(property = "basedir", required = true) // location of the Makefile
    private File mBasedir;
    
    //========================================================================
    
    public void execute() throws MojoExecutionException {
    	Makefile makefile = new  Makefile();
    	makefile.setLog(getLog());
    	makefile.setDirectory(mBasedir);
    	makefile.setProject(mProject);
    	makefile.generate();
    }

}
